<template>
<div>
  <t-table
    rowKey="id"
    :data="data"
    :columns="columns"
    hover
    :pagination="pagination"
    :loading="dataLoading"
  >
    <template #name="{row}">
      {{row.name}}
<!--      <t-link @click="dialog.objId=row.id;dialog.header=row.name;dialog.open_review=true" hover="color" theme="primary">{{row.name}}</t-link>-->
    </template>
    <template #performanceMemberList="{ row }">
      <template v-for="(item,index) in row.performanceMemberList">
        <a class="t-button-link"  :key="index">{{item.name}}</a>{{index+1===row.performanceMemberList.length?'':'、'}}
      </template>
    </template>
    <template #performanceProjectList="{ row }">
      <template v-for="(item,index) in row.performanceProjectList">
        <a class="t-button-link"  :key="index">{{item.businessName}}</a>{{index+1===row.performanceProjectList.length?'':'、'}}
      </template>
    </template>
    <template #performanceStatus="{ row }">
      <t-tag @click="dialog.header=row.name;dialog.objId=row.id;dialog.open_approve_list=true" class="cursor-pointer" :theme="handleTheme(row.performanceStatus, dict.type.achievement_status)" variant="light">
        {{ row.performanceStatus | filterByDict(dict.type.achievement_status) }}
      </t-tag>
    </template>
<!--    <template #op="{ row }">-->
<!--      <t-button   @click="updateData(row)" size="small" variant="text"-->
<!--                  class="t-button-link">-->
<!--        <t-icon name="edit-1" slot="icon"/>-->
<!--        编辑-->
<!--      </t-button>-->
<!--      <t-button size="small"-->
<!--                @click="dialog.objId=row.id;dialog.header=row.name;dialog.open_detail=true"-->
<!--                variant="text" class="t-button-link">-->
<!--        <t-icon name="info-circle" slot="icon"/>-->
<!--        详情-->
<!--      </t-button>-->
<!--      <t-button-->
<!--        theme="danger"-->
<!--        @click="delObj(row)"-->
<!--        size="small"-->
<!--        variant="text" class="t-button-link">-->
<!--        <t-icon name="delete" slot="icon"/>-->
<!--        删除-->
<!--      </t-button>-->
<!--    </template>-->
  </t-table>
  <other-detail-dialog :objId="dialog.objId" :header="dialog.header"  :visible.sync="dialog.open_detail" v-if="dialog.open_detail">
  </other-detail-dialog>
  <file-review :header="dialog.header" :projectFileData="projectFileData" :visible.sync="dialog.open_review" v-if="dialog.open_review" :objId="dialog.objId"></file-review>
</div>
</template>

<script>
// import OtherDetailDialog from "../../../cgzh/other/components/other-detail-dialog.vue";
import fileReview from "../../../cgzh/components/file-review.vue";

export default {
  name: "other-list",
  dicts: ['achievement_status'],
  props: ['deptId', 'idCard'],
  components: {
    // OtherDetailDialog,
    OtherDetailDialog: () => import('../../../cgzh/other/components/other-detail-dialog.vue'),

    fileReview
  },
  data() {
    return {
      projectFileData: [
        {
          id: 1,
          c1: "相关附件",
          c2: "是",
          moduleKey: "otherFJ",
          fileIds: [],
          fileLists: [],
          require: true,
        },
      ],
      serviceOptions: [],
      projectOptions: [],
      dialog: {
        header: "",
        open: false,
        objId: null,
        open_approve_list: false,
        open_detail: false,
        open_review: false,
      },
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        name: "",
        issueDeptName: '',
        serviceCode: '',
        performanceStatus: '',
        declareDeptName: '',
        peopleName: '',
        obtainDateRange: [],
        startObtainDate: '',
        endObtainDate: '',
        businessId: null,
        deptId: this.deptId,
        idCard: this.idCard,
      },
      data: [],
      columns: [
        {
          colKey: "name",
          title: "成果名称",
          align: "center"
        },
        {
          colKey: "issueDeptName",
          title: "颁发单位",
          align: "center"
        },
        {
          colKey: "obtainDate",
          title: "取得时间",
          align: "center"
        },
        {
          colKey: "performanceInfo",
          title: "成果描述",
          align: "center"
        },
        // {
        //   colKey: "declareDeptName",
        //   title: "填报单位",
        //   align: "center"
        // },
        {
          colKey: "performanceMemberList",
          title: "参与人员",
          align: "center"
        },
        {
          colKey: "performanceProjectList",
          title: "项目来源",
          align: "center"
        },
        // {
        //   colKey: "createTime",
        //   title: "创建时间",
        //   align: "center"
        // },
        // {
        //   colKey: "performanceStatus",
        //   title: "成果状态",
        //   align: "center",
        //   fixed: 'right'
        // },
        // {
        //   colKey: "op",
        //   title: "操作",
        //   align: "center",
        //   width: 140,
        //   fixed: 'right'
        // }
      ],
      dataLoading: false,
      pagination: {
        current: 1,
        pageSize: 10,
        total: 0,
        showPageSize: true,
        pageSizeOptions: [10,20,30],
        showFirstAndLastPageBtn: false,
        onChange: (pageInfo) => {
          Object.assign(this.pagination,pageInfo)
          this.queryParams.pageNum = pageInfo.current || 1;
          this.queryParams.pageSize = pageInfo.pageSize;
          this.getList()
        },
      },
    };
  },
  created() {
    this.getList();
  },
  methods:{
    getList() {
      if(this.deptId){
        this.dataLoading = true;
        this.$api.cgzh.other.list(this.queryParams).then(response => {
          this.data = response.rows;
          this.pagination.total = response.total;
          this.dataLoading = false;
        }).catch((e) => {
          this.dataLoading = false;
          this.$message.error(e.toString());
        });
      }else if(this.idCard){
        this.dataLoading = true;
        this.$api.cgzh.other.getJoinList(this.queryParams).then(response => {
          this.data = response.rows;
          this.pagination.total = response.total;
          this.dataLoading = false;
        }).catch((e) => {
          this.dataLoading = false;
          this.$message.error(e.toString());
        });
      }
    },
  }
}
</script>

<style scoped>

</style>
